
Page({
  data: {
    indicatorDots: true, // 轮播图配置
    slideshowList: [], // 轮播图数据
    sudokuList: [], // 金刚区数据
    activityData: [], // 活动区数据
    img: "https://img0.baidu.com/it/u=3940943593,1635399446&fm=253&fmt=auto&app=138&f=JPEG?w=334&h=500",
    img2: "https://img2.baidu.com/it/u=1909579560,1762160284&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500",
    img3: "https://img0.baidu.com/it/u=1031889029,1834453044&fm=253&fmt=auto&app=138&f=JPEG?w=746&h=500",
    tabList: [
      {
        id: 0,
        name: "精品车源"
      },
      {
        id: 1,
        name: "新人练手"
      },
      {
        id: 2,
        name: "豪华品牌"
      }
    ],
    // tab默认值
    tabType: '精品车源',
    // tab切换数据
    tabData: [],
  },
  onShow() {
    this.getSlideshow()
    this.getSudoku()
    this.getTabData()
  },
  // 获取轮播图
  getSlideshow() {
    tt.request({
      url: 'http://localhost:3000/slideshow',
      method: 'get',
      success: (res) => {
        this.setData({
          slideshowList: res.data
        })
      },
    })
  },
  // 获取金刚区
  getSudoku() {
    tt.request({
      url: 'http://localhost:3000/sudoku',
      method: 'get',
      success: (res) => {
        this.setData({
          sudokuList: res.data
        })
      },
    })
  },
  // tab切换
  getTab(item) {
    console.log(111);
    this.tabType = item.currentTarget.dataset.name
  },
  // 获取tab切换数据
  getTabData() {
    tt.request({
      url: 'http://localhost:3000/tabData',
      method: 'get',
      success: (res) => {
        this.setData({
          tabData: res.data
        })
      },
    })
  },
});